package com.vik.webgallery.beans;

import java.io.File;
import java.util.ArrayList;
import java.util.Properties;

import javax.annotation.Resource;

import org.springframework.web.multipart.commons.CommonsMultipartFile;


public class Photo extends BaseBean{
	
	private String fileName;
	
	private String description;
	
	private long galleryId;
	
	private Gallery gallery;
	
	private ArrayList<Comment> comments;
	
	public Photo(){
		regenerateId();
	}
	
	private CommonsMultipartFile file;

    public void setFile(CommonsMultipartFile file) {
        this.file = file;
    }

    public CommonsMultipartFile getFile() {
        return file;
    }

    
	public String getFileName() {
		return fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Gallery getGallery() {
		return gallery;
	}

	public void setGallery(Gallery gallery) {
		this.gallery = gallery;
	}
	
	public long getGalleryId(){
		return galleryId;
	}
	
	

	public void setGalleryId(long galleryId) {
		this.galleryId = galleryId;
	}

	public ArrayList<Comment> getComments() {
		return comments;
	}

	public void setComments(ArrayList<Comment> comments) {
		this.comments = comments;
	}
	
	public void deleteFiles(String basePath){
		logger.debug("Deleting files");
		File f = new File(basePath + File.separator + gallery.getOwner().getUserName() + File.separator + gallery.getRootFolder() + File.separator + "thumbnails" + File.separator + fileName);
		logger.debug("Deleting thumbnail file " + f.getAbsolutePath());
		f.delete();
		f = new File(basePath + File.separator + gallery.getOwner().getUserName() + File.separator + gallery.getRootFolder() + File.separator + fileName);
		logger.debug("Deleting photo file " + f.getAbsolutePath());
		f.delete();
	}

}
